import React from "react";
import { Table, Space } from "antd";

export default function NewsPublish(props) {
  const columns = [
    {
      title: "ID",
      dataIndex: "id",
    },
    {
      title: "新闻标题",
      dataIndex: "title",
      key: "title",
      render: (title, item) => (
        <a href={`#/news-manage/preview/${item.id}`}>{title}</a>
      ),
    },
    {
      title: "作者",
      dataIndex: "author",
      key: "author",
    },
    {
      title: "分类",
      dataIndex: "category",
      key: "category",
      render: (category) => category.title,
    },
    {
      title: "操作",
      key: "action",
      render: (item) => <Space size="middle">{props.button(item.id)}</Space>,
    },
  ];
  return (
    <div>
      <Table
        bordered
        rowKey={(item) => item.id}
        dataSource={props.dataSource}
        columns={columns}
        pagination={{ pageSize: 10 }}
        size="small"
      />
    </div>
  );
}
